﻿using System;
using System.Reflection;

namespace Miao.ML
{
	internal class SerializableFieldInfo : SerializableDataInfo
	{
		private readonly FieldInfo fieldInfo;

		public override string name => fieldInfo.Name;

		public override Type dataType => fieldInfo.FieldType;

		public SerializableFieldInfo(FieldInfo fieldInfo)
		{
			this.fieldInfo = fieldInfo;
		}

		public override object GetValue()
		{
			return GetValue(base.dataObject);
		}

		public override object GetValue(object dataObject)
		{
			return fieldInfo.GetValue(dataObject);
		}

		public override void SetValue(object value)
		{
			SetValue(base.dataObject, value);
		}

		public override void SetValue(object dataObject, object value)
		{
			fieldInfo.SetValue(dataObject, value);
		}
	}
}
